package conexao;

import java.sql.Connection;

public class FabricaDeConexao {
    
     private java.sql.Connection conexao;

    public Connection fazConexao() {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conexao = java.sql.DriverManager.getConnection(
                    "jdbc:mysql://localhost/marmitaria", "root",
                    "alex123");
            System.out.println("Conexão efetuada com sucesso");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conexao;
    }

    @SuppressWarnings("unqualified-field-access")
    public void fechaConexao() {

        try {
            conexao.close();
            System.out.println("Conexão encerrada com sucesso"); //$NON-NLS-1$
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
}
